package com.bruan.map;

import java.util.*;

public class MapTest3 {
    public static void main(String[] args) {
        //Map集合统计人数
        List<String> data = new ArrayList<>();
        String[] selects = new String[]{"A","B","C","D"};
        Random r = new Random();
        for (int i = 0; i < 80; i++) {
            int index = r.nextInt(4);
            data.add(selects[index]);
        }
        System.out.println(data);
        Map<String,Integer> result = new HashMap<>();

        for (String palace : data) {
            if (result.containsKey(palace)){
                result.put(palace,result.get(palace)+1);
            }else {
                result.put(palace,1);
            }
        }
        System.out.println(result);

    }


}
